<?php


/**
 * Notes:
 * PROJECT_NAME : ERP v1.0.0.042823
 * User: 夏鱼儿<397072174@qq.com>
 * Date: 2023/5/16
 * Time: 18:02
 */

namespace app\model;

use think\Model;

class WithdrawApply extends Model
{
    // 定义时间戳字段名
    protected $createTime = 'add_time';

    protected $updateTime = 'update_time';

    /**
     * 隐藏字段
     * @var string[]
     */
    protected $hidden = [
        'remarks',
        'update_time',
    ];
    /**
     * 追加字段
     * @var array
     */
    protected $append = [
        "type_text",
        "bank_type_text",
        "settlement_status_text",
        "withdraw_type_text",
    ];

    /**
     * 关联用户表
     * @return \think\model\relation\BelongsTo
     */
    public function user()
    {
        return $this->belongsTo(PartnerUser::class, 'uid')->bind(['user_name' => 'name']);
    }

    /**
     * 关联用户表
     * @return \think\model\relation\BelongsTo
     */
    public function company()
    {
        return $this->belongsTo(Company::class)->bind(['company_name' => 'name']);
    }

    /**
     * 构造器
     * @param $value
     * @return string
     */
    public function getBankTypeTextAttr($value, $data)
    {
        $types = [1 => '中国银行', 2 => '中国建设银行', 3 => '中国工商银行', 4 => '中国农业银行', 5 => '中国交通银行'];
        return $types[$data['bank_type']];
    }


    /**
     * 构造器
     * @param $value
     * @return string
     */
    public function getTypeTextAttr($value, $data)
    {
        $types = [1 => '司机', 2 => '公司', 3 => '平台', 4 => '渠道'];
        return $types[$data['type']];
    }

    /**
     * 构造器
     * @param $value
     * @return string
     */
    public function getSettlementStatusTextAttr($value, $data)
    {
        $status = [1 => '未审核', 2 => '已打款',3 => '驳回'];
        return $status[$data['settlement_status']];
    }

    /**
     * 构造器
     * @param $value
     * @return string
     */
    public function getWithdrawTypeTextAttr($value, $data)
    {
        $types = [1 => '司机提现', 2 => '公司提现', 3 => '平台提现', 4 => '渠道提现'];
        return $types[$data['type']];
    }

}